package com.whccb.apps.office.document.at;

import com.actionsoft.bpms.commons.at.AbstExpression;
import com.actionsoft.bpms.commons.at.ExpressionContext;
import com.actionsoft.sdk.local.SDK;

public class GetReceivePermSql extends AbstExpression {
	public GetReceivePermSql(ExpressionContext atContext, String expressionValue) {
		super(atContext, expressionValue);
	}

	public String execute(String expression) {
		String uid = getParameter(expression, 1).trim();// 用户账户
		String result = "";
		//根据账户判断类型
		String userType = SDK.getRuleAPI().executeAtScript("@getUnitTypeByUser("+uid+")");
		if("ZHBB".equals(userType)){//总行本部可查看所有，需求提出人谢艳红
			result = " 1=1";
		}else{
			//其他可查看自己单位的。
			//根据用户账户查询HR单位ID
			String hrUnitId = SDK.getRuleAPI().executeAtScript("@getAwsDeptIdByOuterId(@getUserExtInfo("+uid+",HRFIRSTORGID))");
			result = " USERUNITID = '"+hrUnitId+"' ";
		}
		return result;
	}
     
}
